package cn.edu.scau.cmi.zhuangyi.hibernate.factory;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ApplicationContextUtil {
	private static SessionFactory sessionFactory;
//	sessionFactory
	public static SessionFactory getSessionFactory() {
		if(sessionFactory==null) {
			sessionFactory=new Configuration().configure().buildSessionFactory();
		}
		return sessionFactory;
	}

	public static Session getSession(){
		 Session session=getSessionFactory().openSession();
		return session;
	}
}
